Repository navigation
Conversation
There was a problem hiding this comment.
@lszskye, I left two comments for read correctness issues. PTAL.
There was a problem hiding this comment.
@lszskye, I left some comments on the GCC build failure and the sequence-number predicate behavior in append reads and primary-key merges. PTAL.
| } | ||
| if (core_options.RowTrackingEnabled() || core_options.KeyValueSequenceNumberEnabled()) { | ||
| allowed_system_fields.push_back( | ||
| DataField::ConvertDataFieldToArrowField(SpecialFields::SequenceNumber())); |
There was a problem hiding this comment.
Evaluate _SEQUENCE_NUMBER after primary-key merging. GenerateKeyPredicates() excludes non-key names from the table schema, so the virtual _SEQUENCE_NUMBER survives the key-only filter and reaches the format reader for overlapping runs. I reproduced this with two Parquet files holding the same key. A predicate matching the older sequence returned val=10 even though the latest row had val=20 and should have been removed by the post-merge filter. Build the pre-merge predicate from the trimmed primary-key allowlist, preserve the sequence predicate for the merged row, and cover the two-file case.
| allowed_system_fields.push_back( | ||
| DataField::ConvertDataFieldToArrowField(SpecialFields::RowId())); | ||
| } | ||
| if (core_options.RowTrackingEnabled() || core_options.KeyValueSequenceNumberEnabled()) { |
There was a problem hiding this comment.
Require a primary key for the key-value sequence-number option. Both scan and read validation accept _SEQUENCE_NUMBER on an append table with key-value.sequence_number.enabled=true and row tracking disabled. I reproduced a successful TableRead::Create() followed by NextBatch() failing because _SEQUENCE_NUMBER does not exist in the Parquet file. Use the same availability check at both entry points and cover the rejection on an append table alongside the supported primary-key case.
| PAIMON_ASSIGN_OR_RAISE_FROM_ARROW(std::shared_ptr<arrow::StructArray> output, | ||
| arrow::StructArray::Make(arrays, output_schema->fields())); | ||
| auto output = std::make_shared<arrow::StructArray>(arrow::struct_(output_schema->fields()), | ||
| data->length(), arrays); |
There was a problem hiding this comment.
I’d like to understand what this change is for.
| const auto& materialization_schema = context_->EnablePreciseFileIndexEvaluate() | ||
| ? context_->GetReadSchemaPlan()->GetOutputSchema() | ||
| : read_schema; | ||
| auto create_reader = |
There was a problem hiding this comment.
I suggest consolidating EnablePreciseFileIndexEvaluate as much as possible. Right now it’s being special-cased in multiple places, including read_schema, predicate handling, and CreateReader.
| std::move(inner_reader), | ||
| context_->GetReadSchemaPlan()->GetOutputSchema()->field_names(), arrow_pool_); | ||
| } | ||
| return inner_reader; |
There was a problem hiding this comment.
This part feels a bit odd. If you’re constantly rewriting, shouldn’t it no longer be called the inner reader? It seems like you’re returning an inner_reader, and the outer layer should wrap it as well—right?
| /// -> CompleteRowKindBatchReader -> (PredicateBatchReader) -> ConcatBatchReader across files | ||
| /// -> (ProjectionBatchReader) -> CompleteRowKindBatchReader -> (PredicateBatchReader) | ||
| /// -> ConcatBatchReader across files | ||
| /// -> (CompleteIndexScoreFileBatchReader) -> FieldMappingReader |
There was a problem hiding this comment.
I’m a bit curious—why can’t ProjectionBatchReader be placed last, with TopKBatchReader before? That way, we wouldn’t need any special handling for the score field. Also, the setup in GetProjectionFieldNames: it doesn’t return the set of user-projected field names; it includes score-related fields, which is very easy to misunderstand. For example, many times I thought the logic of GetProjectionFieldNames should be something like schema_plan_->GetOutputSchema()->field_names().
| std::move(batch_reader), | ||
| context_->GetReadSchemaPlan()->GetOutputSchema()->field_names(), arrow_pool_); | ||
| } | ||
| return batch_reader; |
There was a problem hiding this comment.
We can wrap this part into a base-class function, something like ApplyProjectionBatchReader since I’ve seen this kind of logic more than three times already.
| SpecialFields::ValidatePredicateFieldNames(field_names, allowed_system_fields)); | ||
| arrow::FieldVector validation_fields = arrow_schema->fields(); | ||
| validation_fields.insert(validation_fields.end(), allowed_system_fields.begin(), | ||
| allowed_system_fields.end()); |
There was a problem hiding this comment.
It looks like there’s similar logic in internal_read_context.cpp as well. Maybe we can merge or reuse it.
| static Result<std::shared_ptr<ReadSchemaPlan>> Create( | ||
| const std::shared_ptr<arrow::Schema>& source_schema, | ||
| const std::shared_ptr<arrow::Schema>& output_schema, | ||
| const std::set<std::string>& required_fields) { |
There was a problem hiding this comment.
I want to know where you added the TODO comment about supporting a non-precise filtering mode later, where we avoid extra I/O for the fields only used in the predicate.
| SpecialFields::ValidatePredicateFieldNames(predicate_fields, /*allowed_system_fields=*/{})); | ||
| PAIMON_RETURN_NOT_OK(PredicateValidator::ValidatePredicateWithSchema( | ||
| *DataField::ConvertDataFieldsToArrowSchema(table_schema->Fields()), | ||
| context->GetPredicate())); |
There was a problem hiding this comment.
allowed_system_fields seems a bit too strict. Java supports this; at least we should add a TODO explaining this inconsistency.
Purpose
Remove the requirement that predicate fields must appear in the output projection. For example, a read can now return only
namewhile filtering onage, without exposingagein the result. This also applies to full-text predicate fields.Introduce
ReadSchemaPlanto separate the requested output schema from the internal schema containing predicate and authorization dependencies. UseProjectionBatchReaderto remove these dependencies after filtering, merging, or masking. Apply this consistently across append, primary-key, data-evolution, realtime, precise-index, query-auth, and format-table reads.The change also addresses several predicate-handling issues:
_ROW_IDand_SEQUENCE_NUMBERcolumns into the physical format reader. Keep these predicates for the existing filtering stage after the values are completed. Predicates on columns already present in the file remain eligible for pushdown.Tests
Add or update coverage for:
API and Format
No public API signature, storage format, or protocol changes.
Documentation
Update predicate API comments and the file-index, realtime, and format-table guides to describe predicates on non-projected fields.
Generative AI tooling
Generated-by: OpenAI Codex (GPT-6)